<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class MobileBindingInputDTO extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     * 'groupId', 'name', 'email', 'mobile'
     * @return array
     */
    public function rules()
    {
        return [
            'mobile' => 'required|regex:/^1[0-9]{10}$/',
            'code' => 'required|regex:/^\d{4}$/',
            'company_id' => 'integer',
            'recommend_id' => 'integer',
        ];
    }

    public function messages()
    {
        return [
            'mobile.required' => '手机号码不能为空',
            'mobile.regex' => '手机号格式不正确',
            'code.required' => '验证码必须填写',
            'code.regex' => '验证码格式不正确',
            'company_id.integer' => '企业参数错误',
            'recommend_id.integer' => '企业参数错误',
        ];
    }
}
